<?php
 //Creates XML string and XML document using the DOM 
 //include("../../classes/albums.class.php");
 include("../../connect.php");
 
 $user_id  = $_GET["user_id"];

 $res_albums = mysql_query("SELECT * FROM albums WHERE id_user_fkn = $user_id ");
 $album_num = mysql_num_rows($res_albums);	
 
 if($album_num > 0)
 {
	 $dom = new DomDocument('1.0'); 
	 $images = $dom->appendChild($dom->createElement('images'));  
	 
	 for($i=0; $i<$album_num; $i++){
	 	 $obj_album = mysql_fetch_object($res_albums);
		 $album_id   = $obj_album->id_album;
		 $album_name = $obj_album->name;
		 $category = $images->appendChild($dom->createElement('category'));
		 $category->setAttribute("name","$album_name"); 
		 $category->setAttribute('id', "$i"); 
		 
		 $res = mysql_query("SELECT * FROM photos WHERE id_album_fkn = $album_id ");
		 while($obj = mysql_fetch_object($res)){			
			 $pic = $category->appendChild($dom->createElement('pic')); 
			
			 $image = $pic->appendChild($dom->createElement("image")); 
			 $image->appendChild($dom->createTextNode("../../photos/normal/normal_$obj->path"));
			                 
			 $thumbnail = $pic->appendChild($dom->createElement('thumbnail')); 
			 $thumbnail->appendChild($dom->createTextNode("../../photos/thumbnail/thumb_$obj->path"));
			                 
			 $caption = $pic->appendChild($dom->createElement('caption')); 
			 $caption->appendChild($dom->createTextNode("$obj->description"));
		 }
	 }
	 //generate xml 
	 $dom->formatOutput = true; // set the formatOutput attribute of 
	                            // domDocument to true 
	 //save XML as string or file 
	 $test1 = $dom->saveXML(); // put string in test1 
	 $dom->save('images.xml'); // save as file 
// echo "hii";
 }

?>
<body>

	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="100%" id="gallery" align="middle">
		<param name="allowScriptAccess" value="sameDomain" />
		<param name="movie" value="my_gal.swf" />
		<param name="quality" value="high" />
		<param name="scale" value="noscale" />
		<param name="bgcolor" value="#333333" />
		<embed src="my_gal.swf" quality="high" scale="noscale" bgcolor="#333333" width="100%" height="100%" name="gallery" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
	</object>

</body>